package com.hoopchina.ui.search;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.os.Handler;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.View.OnClickListener;
import android.view.View.OnCreateContextMenuListener;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

import com.hoopchina.news.R;
import com.hoopchina.meta.NewsItem;
import com.hoopchina.settings.SettingsActivity;
import com.hoopchina.ui.details.DetailsView;
import com.hoopchina.ui.details.FavoritesEngine;
import com.hoopchina.ui.home.HomeView;
import com.hoopchina.ui.main.BaseActivity;
import com.hoopchina.ui.main.INewsListViewObserver;
import com.hoopchina.ui.main.NewsListView;
import com.hoopchina.ui.main.TabBarButtonId;
import com.hoopchina.ui.main.ViewManager;
import com.hoopchina.util.DialogUtils;
import com.hoopchina.util.NetUtil;
import com.hoopchina.util.json.IJsonHandleObserver;
import com.hoopchina.util.json.JsonHandlerThread;
import com.hoopchina.util.search.ISearchHandleObserver;
import com.hoopchina.util.search.SearchHandlerThread;
import com.hoopchina.util.xml.NewsItemXML;
import com.hoopchina.util.xml.XMLDataNetwork;
import com.hoopchina.weibo.ui.BindingDBEngine;
import com.hoopchina.weibo.ui.ForwardingView;
import com.hoopchina.weibo.ui.WeiboAuthActivity;

/**
 * 搜索Acitivity
 * 显示搜索结果和搜索历史
 * @author Guo Baiyu
 *
 */
public class SearchView extends BaseActivity implements IJsonHandleObserver, ISearchHandleObserver,
        ISearchBarChangeObserver, ISearchJsonListListener, INewsListViewObserver, SugCloseButtonCloseObserver {
    
	public static final String Id	                  = "SearchView";
	public static final int	   SEARCH_VIEW_RESULT	  = 1;
	public static final int	   SEARCH_VIEW_SEARCH	  = 0;
	private static SearchView currentView;
	private SearchBar	       mSearchBar	          = null;
	private ListView	       mListViewSearchHistory = null;
	private SearchRecordEngine mSearchRecordEngine	  = null;
	private SearchJsonList	   mSearchJsonList	      = null;
	private boolean	           mIsGotoGetJson	      = true;
	private NewsListView	   mSearchResultListView  = null;
	private int	               mViewState	          = SEARCH_VIEW_SEARCH;
	public static List<NewsItem>	   mSearchResultList	  = null;
	private int	               mCurrentPosition;
	private final int	       MSG_LoadingFinished	  = 1;
	private final int	       MSG_LoadingFailed	  = 2;
	private final int	       MSG_StrartLoading	  = 3;
	private FavoritesEngine OperationDB;
	private int mCurrentViewId = 8;
    private String mSearchKeyWord = null;
    private boolean isSearching = false;
    private int mNextPage = 0;
    private Handler mHandler = new Handler() {
    	public void handleMessage(android.os.Message msg) {

    	    switch (msg.what) {
    	    case MSG_LoadingFinished:
    	    {
              mViewManager.showRefreshButton(true);
    	    }
    		break;

    	    case MSG_LoadingFailed:
    	    	Toast.makeText(mViewManager.getCurrentActivity(), "载入失败，请核查网络...", Toast.LENGTH_SHORT ).show();	
    		break;
    	    case MSG_StrartLoading:
    	    	//Toast.makeText(mViewManager.getCurrentActivity(), "正在加载，请稍后...", Toast.LENGTH_SHORT ).show();        
     	    default:
    		break;
    	    }
    	};
        };
    @Override
    public void onCreate( Bundle savedInstanceState ) {
        super.onCreate( savedInstanceState );
        setContentView( R.layout.searchview );
        
        mMyHandleBackButton = true;
        
        mSearchResultList = new ArrayList<NewsItem>();
        
        currentView = this;
        OperationDB= new FavoritesEngine(this);
        mSearchBar = ( SearchBar ) findViewById( R.id.searchbar );
        mSearchBar.setObserver( this );
        mSearchJsonList = ( SearchJsonList ) findViewById( R.id.searchJsonView );
        mSearchJsonList.setJosnViewVisibility( SearchJsonList.GONE );
        mSearchJsonList.setListener( this );
//        mSearchJsonList.addFooterViewForClearButton();
        mSearchRecordEngine = new SearchRecordEngine( this );

        mListViewSearchHistory = ( ListView ) findViewById( R.id.listViewSearchHistory );

        UpdateSearchHistoryList();
        
        mListViewSearchHistory.setOnItemClickListener( new OnItemClickListener() {
            @Override
            public void onItemClick( AdapterView<?> arg0, View view, int position, long arg3 ) {
                String searchText = ((SearchRecordListTextItem)view).getItemText().trim();
                // UserOperateTraceEngine.Trace( SearchHistoryActivity.this, new UserOperate(
                // UserOperate.kLogSearchPressSearch, searchText, null, null ) );
                setSearchBarText( searchText );
                onSearch( searchText );
            }
        } );
        
        mSearchResultListView = ( NewsListView ) findViewById( R.id.listViewSearchResult );
        mSearchResultListView.setFastScrollEnabled(true);

        mSearchResultListView.setObserver( this );
        mSearchResultListView.setDataList(mSearchResultList,true);
        mSearchResultListView.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
			@Override
			public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
				//take user operation trace				
					menu.setHeaderTitle("新闻功能");
					menu.add(0, 0, 0, "查看");
					menu.add(0, 1, 0, "转发");
					menu.add(0, 2, 0, "收藏");
			}
		});
        
        widgetSearchResult();
    }
    
    public void widgetSearchResult(){
    	Bundle bundle = getIntent().getExtras();
    	if(bundle != null){
    		String hotword = (String) bundle.get("hotword");
    		System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>liguan-search222="+hotword);
    		setSearchBarText( hotword );
//            onSearch( hotword );
    		onSearchBarChange(SearchBar.SEARCH_BAR_EDITER_ENTER, hotword);
    	}
    }
    

    /*
     * 
     */
    public void UpdateSearchHistoryList() {
        long count = mSearchRecordEngine.getSearchRecordCount();

        if ( count > 0 ) {
            SearchRecordListAdapter listItemAdapter = new SearchRecordListAdapter( this );
            loadSearchHistoryData( listItemAdapter );
            mListViewSearchHistory.setAdapter( listItemAdapter );

            DisplayList( true );
        }
        else {
            DisplayList( false );
        }
    }

    /**
     * 
     */
    private void DisplayList( boolean isVisble ) {
        if ( isVisble ) {
            mListViewSearchHistory.setVisibility( ListView.VISIBLE );
        }
        else {
            mListViewSearchHistory.setVisibility( ListView.INVISIBLE );
        }
    }

    /*
     * 
     */
    private void loadSearchHistoryData( SearchRecordListAdapter listItemAdapter ) {
        List<SearchRecord> list = new ArrayList<SearchRecord>();
        list = mSearchRecordEngine.getSearchRecordList();
        Collections.reverse(list);
//        int count = list.size();

//        for ( int i = count - 1; i >= 0; i-- ) {
//            SearchRecordListTextItem textItem = new SearchRecordListTextItem( this );
//            textItem.setItemText( list.get( i ).getSearchRecordText() );
//            textItem.setDeletButotnTag( list.get( i ).getSearchRecordText() );
//            textItem.setOnSearchHistoryDeleteItemButtonClickListener( new SearchHistoryDeleteItemButtonClickListener(
//                    SearchView.this ) );
//            listItemAdapter.addItem( textItem );
//        }
        listItemAdapter.addAllItem( list );

    }

    /* (non-Javadoc)
     * @see android.app.Activity#onPause()
     */
    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        mSearchBar.dispSoftMethodInput( false );
        mViewState = getViewState();

            
        super.onPause();
    }

    public int getViewState() {
        if (mSearchResultListView.getVisibility() == NewsListView.VISIBLE) {
        	return SEARCH_VIEW_RESULT;
        }
        else {
            return SEARCH_VIEW_SEARCH;
        }
    }
    
    
    @Override
    public void onResume() {
        super.onResume();
        mViewManager.setTitle( this.getResources().getString( R.string.app_tabbar_search_news ) );
        mViewManager.hideLeftButton();
        mViewManager.setStatus( "" );
        mViewManager.setTabBarVisibility( true );
        
        mViewManager.setAssistButton( "", R.drawable.titlebar_btn_refresh_selector, new OnClickListener() {
            @Override
            public void onClick(View v) {
//                mViewManager.showView(
//                        DemoActivity12.Id,
//                        DemoActivity12.class,
//                        true, 
//                        null );
            	updatelist();
            }
        } );
        
//        Bundle b = getIntent().getExtras();
//        String hotword;
//        if(b != null){
//        	hotword = b.getString("hotword");
//        
//	        if(hotword != null)
//	        	onSearch(hotword);
//        }
        
        displaySearchResult( SEARCH_VIEW_RESULT == mViewState );
        clearSearchBarFocus();
        UpdateSearchHistoryList();
        
        
        if(getViewState() == SEARCH_VIEW_SEARCH) {
        	mViewManager.setTabBarVisibility( true );
//            mSearchBar.dispSoftMethodInput( true );
        }
        else {    
        	mViewManager.setTabBarVisibility( false );
        }
        
    }

    @Override
    public void showJson( List<String> jsonKeywordList ) {
        if ( null == jsonKeywordList ){
            return;
        }
        SearchJsonListAdapter listItemAdapter = new SearchJsonListAdapter( SearchView.this );
        listItemAdapter.setSugCloseButtonCloseObserver(SearchView.this);
        int count = jsonKeywordList.size();
        if ( 0 == count || 1 == count ) {
            mSearchJsonList.setJosnViewVisibility( SearchJsonList.GONE );
        } else {
//            for ( int i = 1; i < count; i++ ) {
//                SearchJsonListTextItem jsonItem = new SearchJsonListTextItem( this );
//
//                jsonItem.setItemText( jsonKeywordList.get( i ) );
//
//                listItemAdapter.addItem( jsonItem );
//            }
            listItemAdapter.addAllItem( jsonKeywordList );

            mSearchJsonList.setAdapter( listItemAdapter );
//            mSearchJsonList.addFooterViewForClearButton();
            mSearchJsonList.setJosnViewVisibility( SearchJsonList.VISIBLE );
        }
        mSearchJsonList.displayJosnLoading( false );
    }

    @Override
    public void notifyGetJsonError( int errorId ) {
        mSearchJsonList.setJosnViewVisibility( SearchJsonList.GONE );
    }

    @Override
    public void startGetJson() {
        mSearchJsonList.setJosnViewVisibility( SearchJsonList.VISIBLE );
        mSearchJsonList.displayJosnLoading( true );
    }

    /**
     * 
     * @return the mIsGotoGetJson
     */
    public boolean isGotoGetJson() {
        return mIsGotoGetJson;
    }

    /**
     * 
     * @param mIsGotoGetJson the mIsGotoGetJson to set
     */
    public void setIsGotoGetJson( boolean isGotoGetJson ) {
        this.mIsGotoGetJson = isGotoGetJson;
    }

    @Override
    public void onSearchBarChange( int state, String keyWord ) {
        switch ( state ) {
            case SearchBar.SEARCH_BAR_BUTTON_CLICKED:
            case SearchBar.SEARCH_BAR_EDITER_ENTER:
                setIsGotoGetJson( false );
                mSearchJsonList.setJosnViewVisibility( SearchJsonList.GONE );
                onSearch(keyWord);
                UpdateSearchHistoryList();
                break;
            case SearchBar.SEARCH_BAR_EDITER_CLICKED:
                setIsGotoGetJson( true );
                if ( !keyWord.equals( "" ) ) {
                    getJson( keyWord );
                }
                break;
            
            case SearchBar.SEARCH_BAR_TEXT_CHANGE:
                if ( 0 == keyWord.length() ) {
                    mSearchJsonList.setJosnViewVisibility( SearchJsonList.GONE );
                    return;
                }
    
                if ( !keyWord.equals( "" ) && isGotoGetJson() ) {
                    getJson( keyWord );
                }
                else {
                    mSearchJsonList.setJosnViewVisibility( SearchJsonList.GONE );
                }
                break;

            default:
            break;
        }

    }

    private void getJson( String keyWord ) {
        JsonHandlerThread jht = new JsonHandlerThread( this, keyWord );
        jht.setObserver( this );
        jht.start();
    }

    public void onDeleteItemButtonClick( String searchHistoryItem ) {
        SearchRecordEngine mSearchRecordEngine = new SearchRecordEngine( this );
        mSearchRecordEngine.removeSearchRecord( new SearchRecord( searchHistoryItem ) );
        UpdateSearchHistoryList();
    }

    @Override
    public boolean onPrepareOptionsMenu( Menu menu ) {
        menu.clear();
        MenuInflater inflater = getMenuInflater();
        if(getViewState() == SEARCH_VIEW_SEARCH){
        inflater.inflate( R.menu.searchview, menu );
        }else
        {
        	inflater.inflate( R.menu.searchviewresult, menu );
        }
        return true;

    }

    
    @Override
    public boolean onOptionsItemSelected( MenuItem item ) {
        switch ( item.getItemId() ) {
            case R.id.menu_searchview_settings:
            case R.id.menu_searchresultview_settings:
            	 Intent intent = new Intent();
                 intent.setClass(SearchView.this, SettingsActivity.class);
     			 startActivity(intent);
                break;
          
            case R.id.menu_searchview_clear_search_history:
                mSearchRecordEngine.clearSearchRecord();
                DisplayList( false );
                break;
    
            case R.id.menu_searchview_exit:
            	DialogUtils.showExitDialog(this);
                break;
           
            case R.id.menu_searchresultview_subscription:
            	
                break;
           
            case R.id.menu_searchresultview_home:
            	mViewManager.showViewAndChangeTab(HomeView.Id, HomeView.class, null, TabBarButtonId.EHOME);//showView(GoalHi.Id, GoalHi.class,
//				true, null, true);
                break;

            default:
                break;
        }
        return false;
    }

    @Override
    public void searchStart() {
        isSearching  = true;
        // TODO Auto-generated method stub 
    }

    @Override
    public void searchResultNothing() {
        // TODO Auto-generated method stub
    	mSearchResultList.clear();
    	mSearchResultListView.notifyDataSetChanged();
        displaySearchResult( true );
        //mSearchResultListView.setLoadMoreProgressBarVisibility(View.INVISIBLE);
        isSearching = false;
    }

    @Override
    public void searchResultShow( List<NewsItem> listSearchResult ) {
    	mSearchResultList.clear();
    	mSearchResultList.addAll(listSearchResult);
//        mSearchResultListView.setDataList(mSearchResultList);
        mSearchResultListView.notifyDataSetChanged();
        displaySearchResult( true );
        isSearching = false;
    }

    @Override
    public void searchResultRefresh(List<NewsItem> addListSearchResult) {
    	mSearchResultList.addAll(addListSearchResult);
        mSearchResultListView.notifyDataSetChanged();
        displaySearchResult( true );
        isSearching = false;
    }

    @Override
    public void searchNetworkError() {

        displaySearchResult( false );
        isSearching = false;
   }

    @Override
    public void searchError() {
        displaySearchResult( false );
        isSearching = false;
    }
    
    /**
     * on Search
     * @param strSearch
     */
    public void onSearch( String strSearch ) {
        if ( strSearch == null ) {
            return;
        }
        
        if ( isSearching ) {
           // Toast.makeText( this, "Searching...", 2000 ).show();
            return;
        }

        strSearch = strSearch.replaceAll( "'", "" );
        mSearchKeyWord = strSearch;
        if ( !strSearch.equals( "" ) ) {
            mSearchBar.setCurrentSearchText( strSearch );

            mSearchBar.dispSoftMethodInput( false );

            mSearchRecordEngine.addSearchRecord( new SearchRecord( strSearch ) );
            UpdateSearchHistoryList();

            SearchHandlerThread sht = new SearchHandlerThread( SearchView.this, strSearch,
                    SearchHandlerThread.MEDIA_TYPE_DEFAULT, 0 );
            sht.setObserver( SearchView.this );
            sht.start();
        }
        else {
            mSearchBar.dispSoftMethodInput( true );
        }
    }

    
    @Override
    public void onJsonListItemClick( String searchText ) {
        mSearchJsonList.setJosnViewVisibility( SearchJsonList.GONE );
        UpdateSearchHistoryList();
        setSearchBarText( searchText );
        onSearch( searchText );
    }
    
    void setSearchBarText( String searchText ) {
        setIsGotoGetJson( false );
        mSearchBar.setSearchEditText( searchText );
    }
    
    public void setSearchBarFocus() {
        mSearchBar.setEditFocus();
    }
      private void clearSearchBarFocus() {
        mSearchBar.clearEditFocus();
    }
      
    @Override
    public void onNewsListItemClick( AdapterView<?> parent, View view, int position, long id ) {
        goToDetailsView(position);
    }

    public void goToDetailsView(int position)
    {
		Bundle bundle = new Bundle();
		bundle.putInt("SearchPosition", position);
		bundle.putInt("Type", mCurrentViewId);		
 		mViewManager.setTabBarVisibility(false);
        mViewManager.showClearOnTopView( DetailsView.Id, DetailsView.class, true, bundle);    
    }
    @Override
    public void onNewsListItemLongClick( AdapterView<?> parent, View view, int position, long id ) {
//        Toast.makeText( this, "long click:"+position, 600 ).show();
    	mCurrentPosition = position;
    }
    
    void displaySearchResult( boolean isDisp ){
        mMyHandleBackButton = isDisp;

        if ( isDisp ){
            mViewManager.showAssistButton(true);
            mViewManager.setTabBarVisibility( false );
            mSearchResultListView.setVisibility( NewsListView.VISIBLE );
            
        }
        else {
            mViewManager.showAssistButton(false);

            mViewManager.setTabBarVisibility( true );
            mSearchResultListView.setVisibility( NewsListView.GONE );
        }
    }


    /* (non-Javadoc)
     * @see com.hoopchina.ui.main.BaseActivity#goBack()
     */
    @Override
    protected void goBack() {
        if (mSearchResultListView.getVisibility() == NewsListView.VISIBLE)
            displaySearchResult(false);

        else {
            mMyHandleBackButton = false;

            super.goBack();
        }  
    }
    
    @Override
    public void clickToTop() {
//        mSearchResultListView.smoothScrollToPosition(0);;
    }


	@Override
	public void onNewsListHeaderClick(AdapterView<?> parent, View view,
			int position, long id) {
		// TODO Auto-generated method stub
		
	}
	
	
	@Override
	public boolean onContextItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case 0:
	    	goToDetailsView(mCurrentPosition);
			break;
		case 1:
			final CharSequence[] items = {
          		  getResources().getString(R.string.forward_select_item_sina)
          		, getResources().getString(R.string.forward_select_item_tencent)
          		, getResources().getString(R.string.forward_select_item_sohu)
          		, getResources().getString(R.string.forward_select_item_netease)
          		, getResources().getString(R.string.forward_select_item_renren)}; 
            AlertDialog.Builder builder = new AlertDialog.Builder(SearchView.this);
            builder.setTitle(getResources().getString(R.string.forward_select_dialog_title));
            builder.setItems(items, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int item) {
                   Bundle aBundle = new Bundle();
                   aBundle.putInt("WeiboType", item);
                   aBundle.putString("Title", mSearchResultList.get(mCurrentPosition).getTitle());
                   aBundle.putString("ImageUrl", mSearchResultList.get(mCurrentPosition).getImgUrl());
                   aBundle.putString("NewsUrl", mSearchResultList.get(mCurrentPosition).getUrl());
                   aBundle.putString("Abstract", mSearchResultList.get(mCurrentPosition).getAbs());
                   aBundle.putString("Author", mSearchResultList.get(mCurrentPosition).getAuthor());
                   aBundle.putBoolean("FromBindingPage", false);
	           		BindingDBEngine mEngine = new BindingDBEngine(SearchView.this);
	           		
	        		if (!NetUtil.checkNet(SearchView.this)) {
	        			Toast.makeText(mViewManager.getCurrentActivity(),
	        					getResources().getString(R.string.app_no_network),
	        					Toast.LENGTH_SHORT).show();
	        		}
	        		else
	        		{
		         		if ( mEngine.isBinding( item ) ) {
		         			ForwardingView.setOldView(SearchView.Id, SearchView.class);
		                     ViewManager.getInstance().showClearOnTopView( ForwardingView.Id,
		                     		ForwardingView.class, false, aBundle);
		         		} else {
		         			WeiboAuthActivity.setOldView(SearchView.Id, SearchView.class);
		                     ViewManager.getInstance().showClearOnTopView(WeiboAuthActivity.Id,
		                    		 WeiboAuthActivity.class, false, aBundle);
		         		}	        			
	        		}
                }
            });
            builder.create().show();

			break;			
		case 2:
	    	Cursor cursor = OperationDB.queryByTitle(mSearchResultList.get(mCurrentPosition-1).getTitle());
    		if ( cursor.getCount() == 0 )
    		{
    			Toast.makeText(this, getString( R.string.app_save_sucess ), 2000).show();	
    	    	OperationDB.insert(mSearchResultList.get(mCurrentPosition-1).getUrl(), 
    	    			mSearchResultList.get(mCurrentPosition -1).getTitle(), 
    	    			mSearchResultList.get(mCurrentPosition -1).getAbs(), 
    	    			mSearchResultList.get(mCurrentPosition-1).getAuthor(), 
    	    			mSearchResultList.get(mCurrentPosition-1).getTime(),
    	    			mSearchResultList.get(mCurrentPosition-1).getImgUrl());
    		}else
    		{
    			Toast.makeText(this, getString( R.string.app_cannot_save_again ), 2000).show();
    		}
    		cursor.close();
			break;
		default:
			break;
		}	
			
			return super.onContextItemSelected(item);
	}


	@Override
	public void onClickLoadMoreButton() {
		// TODO Auto-generated method stub
		//int pageNO;
		mNextPage = mNextPage+20;
        SearchHandlerThread sht = new SearchHandlerThread( SearchView.this, mSearchKeyWord,
                SearchHandlerThread.MEDIA_TYPE_FLUENTLY, mNextPage );
        sht.setObserver( SearchView.this );
        sht.start();
//        InputStream   	instreamChannelInfo = this.getClass().getClassLoader().getResourceAsStream("channellist.xml");
//        NewsItemXML newsResult = new NewsItemXML();
//        List<NewsItem>  newsList = newsResult.getNewsList( instreamChannelInfo );
//        listSearchResult.addAll(newsList);
//        mListView.setDataList(mNewsList);
//        
//        
//        mSearchResultListView.setDataList(listSearchResult);
//        mSearchResultListView.notifyDataSetChanged();
//        displaySearchResult( true );
	}
	
    public void updatelist()
    {
    	mViewManager.showRefreshButton(false);
    	new Thread() {
    	    public void run() {
    	    	URLConnection Urlconnection = null;
    	    	  try{   	    		
                  	Urlconnection = XMLDataNetwork.getHttpConnection("http://wei.si/news/news.xml");
                      }catch(SocketTimeoutException e){
                    	  mHandler.sendEmptyMessage(MSG_LoadingFailed);
                    	  return;
                      }catch(MalformedURLException e){
                      	  e.printStackTrace();
                      	  return;
                      }catch(IOException e){
                    	  mHandler.sendEmptyMessage(MSG_LoadingFailed);
                    	  return;
                      }
                      mHandler.sendEmptyMessage(MSG_StrartLoading);
//                  NewsItemXML newsResult = new NewsItemXML();
                  try {
  					@SuppressWarnings("unused")
                    List<NewsItem> mNewsList = NewsItemXML.getNewsList(Urlconnection.getInputStream());
  				} catch (IOException e) {
  					mHandler.sendEmptyMessage(MSG_LoadingFailed);
  				}
  				mHandler.sendEmptyMessage(MSG_LoadingFinished);
    	    }
    	}.start();
    }
    
    public static SearchView getSearchView(){
		return currentView;
    }


	@Override
	public void autoLoadMoreList() {
		// TODO Auto-generated method stub
		
	}

	@Override
    public void onClickSugColseButtonListener() {
	    // TODO Auto-generated method stub
        mSearchJsonList.setJosnViewVisibility( SearchJsonList.GONE );
    }

}
